﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WFCSharp_I
{
    public partial class DataBinding : Form
    {
        private Student student = new Student("Mr A", 1);

        public DataBinding()
        {
            InitializeComponent();
        }

        private void updateButton_Click(object sender, EventArgs e)
        {
            student.Name += DateTime.Now.Second;
            //student.Name = nameText.Text;
            //student.Score = float.Parse(scoreText.Text);

            //messageLabel.Text = student.Name + ", " + student.Score.ToString();
        }

        private void DataBinding_Load(object sender, EventArgs e)
        {
            nameText.DataBindings.Add("Text", student, "Name");
            scoreText.DataBindings.Add("Text", student, "Score");
            messageLabel.DataBindings.Add("Text", student, "Name");
            //nameText.Text = student.Name;
            //scoreText.Text = student.Score.ToString();

            //messageLabel.Text = student.Name + ", " + student.Score.ToString();
        }
    }
}
